package com.carambatv.android.ui;

import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;

import com.carambatv.android.R;
import com.carambatv.android.utils.ToastUtil;

public class SplashActivity extends GAActivity {
	private static final long SPLASH_DISPLAY_LENGTH = 1500;
	private CarambaApplication app;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		
		overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);

		app = (CarambaApplication) getApplicationContext();
		if (!app.isInternetPresent())
			ToastUtil.showNoNetwork(getApplicationContext());

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {

				final Intent mainIntent = new Intent(SplashActivity.this, HomeActivity.class);
				startActivity(mainIntent);
				finish();
			}
		}, SPLASH_DISPLAY_LENGTH);

	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		AnimationDrawable frameAnimation = (AnimationDrawable) findViewById(R.id.image_animation).getBackground();
		if (hasFocus) {
			frameAnimation.start();
		} else {
			frameAnimation.stop();
		}
	}

}
